#!/bin/bash

# export VERSION=${VERSION:-$(git describe --tags --dirty)}
# export VERSION=$(date +'%Y%m%d')
# export GOFLAGS="-ldflags \"-X=gitee.com/mkwchecking/sr-admin/version.Version=${VERSION#v}\""

app=$1

case $app in
"knowledge")
    GOOS=darwin GOARCH=amd64 go build -ldflags "-X=gitee.com/mkwchecking/sr-admin/version.Version=${VERSION#v}" --tags "knowledge" -o ./dist/knowledge-amd64 ./main.go
    GOOS=darwin GOARCH=arm64 go build -ldflags "-X=gitee.com/mkwchecking/sr-admin/version.Version=${VERSION#v}" --tags "knowledge" -o ./dist/knowledge-arm64 ./main.go
    lipo -create -output ./dist/knowledge ./dist/knowledge-amd64 ./dist/knowledge-arm64
    ;;
"web")
    go build --tags "web" -o./dist/srAdminWeb./main.go
    ;;
"all")
    go build --tags "all" -o./dist/srAdmin./main.go
    ;;
*)
    go build --tags "all" -o./dist/srAdmin./main.go
    ;;
esac
